package com.example.asus.widget1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewActivity extends AppCompatActivity {

    private List<Imagetext> imagetextList=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);

        init();

        android.support.v7.widget.RecyclerView recyclerView = (android.support.v7.widget.RecyclerView)findViewById(R.id.recycler_view);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);

        recyclerView.setLayoutManager(layoutManager);
        RecyclerViewAdapter adapter = new RecyclerViewAdapter(imagetextList);
        recyclerView.setAdapter(adapter);
    }

    private void init(){
        for(int i=0;i<5;i++){
            Imagetext a = new Imagetext ( "aaa", R.mipmap.ic_launcher );
            imagetextList.add ( a );
            Imagetext b = new Imagetext ( "bbb", R.mipmap.ic_launcher );
            imagetextList.add ( b );
            Imagetext c = new Imagetext ( "ccc", R.mipmap.ic_launcher );
            imagetextList.add ( c );
            Imagetext d = new Imagetext ( "ddd", R.mipmap.ic_launcher );
            imagetextList.add ( d );
            Imagetext e = new Imagetext ( "eee", R.mipmap.ic_launcher );
            imagetextList.add ( e );
            Imagetext f = new Imagetext ( "fff", R.mipmap.ic_launcher );
            imagetextList.add ( f );
        }
    }
}


